# 进程间通信
import random
from multiprocessing import Queue, Process
from time import sleep


def down(q):
    while True:
        sleep(random.random() * 6)
        print(q.get())


def up(q):
    while True:
        sleep(random.random() * 2)
        q.put(random.randint(1, 10))
        print("放入完毕")


if __name__ == '__main__':
    q = Queue(5)
    p = Process(target=down, args=(q,))
    p1 = Process(target=up, args=(q,))

    p.start()
    p1.start()

    p.join()
    p1.join()